﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AFSharedLibrary.Wizards;
using AFSharedLibrary;

namespace UIDesigner.Designers.Controls
{
    public class ctrlWizPanelOptionLabels : ctrlWizFrameBase
    {
        private ctrlCreateNewWizard m_ctrlContainer;
        private TableLayoutPanel LabelPanel;
        private int m_nConstructorIndex;
        private List<TextBox> m_rgLabelTextBoxes = new List<TextBox>();

        public List<TextBox> LabelTextBoxes
        {
            get { return m_rgLabelTextBoxes; }
        }

        #region " Windows Form Designer generated code "

        public ctrlWizPanelOptionLabels()
        {
            //This call is required by the Windows Form Designer.
            InitializeComponent();
        }

        //Form overrides dispose to clean up the component list.
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (!(components == null))
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }

        private Label lblHeader;

        //Required by the Windows Form Designer
        private System.ComponentModel.IContainer components;

        //NOTE: The following procedure is required by the Windows Form Designer
        //It can be modified using the Windows Form Designer.  
        //Do not modify it using the code editor.
        [System.Diagnostics.DebuggerStepThrough()]
        private void InitializeComponent()
        {
            this.lblHeader = new System.Windows.Forms.Label();
            this.LabelPanel = new System.Windows.Forms.TableLayoutPanel();
            this.SuspendLayout();
            // 
            // lblHeader
            // 
            this.lblHeader.Dock = System.Windows.Forms.DockStyle.Top;
            this.lblHeader.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblHeader.ForeColor = System.Drawing.Color.Navy;
            this.lblHeader.Location = new System.Drawing.Point(0, 0);
            this.lblHeader.Name = "lblHeader";
            this.lblHeader.Size = new System.Drawing.Size(310, 18);
            this.lblHeader.TabIndex = 0;
            this.lblHeader.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // LabelPanel
            // 
            this.LabelPanel.ColumnCount = 1;
            this.LabelPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
            this.LabelPanel.Dock = System.Windows.Forms.DockStyle.Fill;
            this.LabelPanel.Location = new System.Drawing.Point(0, 18);
            this.LabelPanel.Name = "LabelPanel";
            this.LabelPanel.RowCount = 1;
            this.LabelPanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
            this.LabelPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
            this.LabelPanel.Size = new System.Drawing.Size(310, 248);
            this.LabelPanel.TabIndex = 1;
            // 
            // ctrlWizPanelOptionLabels
            // 
            this.BackColor = System.Drawing.SystemColors.Control;
            this.Controls.Add(this.LabelPanel);
            this.Controls.Add(this.lblHeader);
            this.Name = "ctrlWizPanelOptionLabels";
            this.Size = new System.Drawing.Size(310, 266);
            this.ResumeLayout(false);

        }
        #endregion

        public ctrlWizPanelOptionLabels(ctrlWizFrameBase ctrlPrevious, IWizardFrameContainer objContainer, int nConstructorIndex) : base(ctrlPrevious, objContainer)
        {
            Construct objConstruct;
            ConstructorMapItem objItem;

            InitializeComponent();

            m_nConstructorIndex = nConstructorIndex;
            m_ctrlContainer = (ctrlCreateNewWizard)objContainer;
            objConstruct = m_ctrlContainer.BusinessObject;

            objItem = objConstruct.ConstructorMap[m_nConstructorIndex];

            LabelPanel.RowStyles.Clear();
            LabelPanel.RowCount = 0;

            foreach (ParmItem objParmItem in objItem.ParmItems.Values)
            {
                TextBox txtLabel = new TextBox();
                RowStyle objStyle = new RowStyle();

                txtLabel.Margin = new Padding(10, 5, 5, 5);
                txtLabel.Text = objParmItem.Name;
                txtLabel.Width = (int) (((float) this.Width) * .8f);

                LabelPanel.RowCount++;

                objStyle.SizeType = SizeType.Absolute;
                objStyle.Height = txtLabel.Height + 2;
 
                LabelPanel.RowStyles.Add(objStyle);

                m_rgLabelTextBoxes.Add(txtLabel);
                LabelPanel.Controls.Add(txtLabel, 0, LabelPanel.RowCount - 1);
            }

            this.Name = base.Name + m_nConstructorIndex.ToString();

            lblHeader.Text = objItem.Name + " (Constructor #" + (m_nConstructorIndex + 1).ToString() + ")";
        }

        public int ConstructorIndex
        {
            get 
            { 
                return m_nConstructorIndex; 
            }
        }

        public override string Caption
        {
            get 
            { 
                return "Option Labels"; 
            }
        }

        public override System.Drawing.Image Image
        {
            get 
            { 
                return null; 
            }
        }

        public override ctrlWizFrameBase GetNextFrame(ctrlWizFrameBase ctrlPrevious)
        {
            return this.PreviousFrame.GetNextFrame(ctrlPrevious);
        }
    }
}
